﻿using Microsoft.AspNetCore.Http;
using System;
using System.Threading.Tasks;

namespace server02_path
{
    class Program
    {
        static void Main(string[] args)
        {
            var server = new light.http.server.httpserver();
            server.SetFailAction(on404);
            server.SetHttpAction("/abc", onAbc);
            server.SetHttpAction("/aaa", onAaa);
            server.SetHttpController("/con_abc", new MyController());
            server.Start(1988);
            Console.WriteLine("server on:1988");
            while(true)
            {
                Console.ReadLine();
            }
        }
        static async Task on404(HttpContext context)
        {
            await context.Response.WriteAsync("you got a 404");
        }
        static async Task onAbc(HttpContext context)
        {
            await context.Response.WriteAsync("you got a abc");

        }
        static async Task onAaa(HttpContext context)
        {
            await context.Response.WriteAsync("you got a aaa");
        }
    }
    class MyController : light.http.server.IController
    {
        public async Task ProcessAsync(HttpContext context, string path)
        {
            await context.Response.WriteAsync("you got a MyController");
        }
    }

}
